<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
		
			div{
				position: relative;
				border: 1px solid;
				width: 200px;
				height: 100px;
			}
			p{
				position: absolute;
				left: 20px;
				right: 20px;
				border: 1px solid red;
			}
		</style>
	</head>
	<body>
		<div>
			<p>我是子元素·</p>
		</div>
		<script type="text/javascript">
			console.log(document.querySelector("p").offsetWidth);//160  200-20-20
		</script>
	</body>
</html>
